package com.pubinfo.passbook.common.model.http.request.AutoCreateWriteoff;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import com.pubinfo.passbook.common.model.bo.witeoff.ContractWiteoffBase;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@JacksonXmlRootElement(localName = "requestMessage")
public class ContractAutoCreateWriteoffMessageList<T> implements Serializable {
  //private static final long serialVersionUID = -4263564369107973676L;
  @JacksonXmlProperty(localName = "processCode")
  private String processCode = null;  // SFPTFQJT-CSKJ_02
  @JacksonXmlElementWrapper(localName = "writeoffItems")
  @JacksonXmlProperty(localName = "item")
  private List<T> item;

  public ContractAutoCreateWriteoffMessageList() {
  }

  public ContractAutoCreateWriteoffMessageList(ContractWiteoffBase jobOrRetireDTO) {
    item = new ArrayList<>();
    item.add((T) jobOrRetireDTO);
    if (jobOrRetireDTO.getIsProcessShort()) {
      this.processCode = "SFPTFQJT-CSKJ_02";
    }
  }

}
